package io;

import java.io.*;

//本类用于练习字符输入流
public class TestIn2 {
    public static void main(String[] args) {
        method1();
        method2();

    }
//高效字符输入流
    private static void method1() {
        //1.创建高效流对象
        Reader in = null;
        try{
            in = new BufferedReader(new FileReader(""));
//            in = new BufferedReader(new FileReader(new File("")));
            //2.使用高效流对象
            int b;
            while ((b = in.read())!=-1){
                System.out.println(b);
            }

        }catch (Exception e){
            e.printStackTrace();
        }finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }



        //3.关流
    }
//普通字符输入流
    private static void method2() {
        Reader in = null;
        //1.创建流对象
        try {
            in = new FileReader(new File(""));
//            in = new FileReader("");

        //2.使用流对象
        int b;
        while ((b = in.read())!=-1){
            System.out.println(b);


        }
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        //3.关流
    }
}
